/*
 * UnaryDrankOperatorAst.cpp
 *
 *  CreDrankd on: 1 Nov 2010
 *      Author: ph1109
 */

#include <MAlice/Ast/UnaryDrankOperatorAst.h>
#include <MAlice/Ast/IntegerLiteralAst.h>
#include <MAlice/Ast/BinarySubOperatorAst.h>
#include <MAlice/Ast/AssignmentOperatorAst.h>

#include <MAlice/Parser/location.hh>
namespace MAlice
{

UnaryDrankOperatorAst::UnaryDrankOperatorAst(location loc, VariableAst* lhs) :
	UnaryOperatorAst(loc, "drank", lhs)
{
	MALICE_TRACE;
}

UnaryDrankOperatorAst::~UnaryDrankOperatorAst()
{
	MALICE_TRACE;
}

llvm::Value* UnaryDrankOperatorAst::generate()
{
	MALICE_TRACE;
	return AssignmentOperatorAst(mLocation,
			reinterpret_cast<VariableAst*> (getLHS()),
			new BinarySubOperatorAst(mLocation,
					getLHS(),
					new IntegerLiteralAst(mLocation,1))
	).generate();
}

}
